var nowId = 0
function getUserId(){
    $.ajax({
        url: "/user/getNowIdInfo",
        success(response){
            if (response.user.flag != null && response.user.flag){
                var name = document.getElementById("name");
                var password = document.getElementById("pwd");
                document.getElementById("userid").setAttribute("value",response.user.id)
                name.value = response.user.name
                password.value = "123456"
            }
        }
    })
}

function submitData() {
    var name = document.getElementById("name");
    var password = document.getElementById("pwd");
    if (name.value != null && name.value != '' && password.value != "" && password.value != null){
        name = name.value
        password = password.value
        id = document.getElementById("userid").getAttribute("value")
        $.ajax({
            url: "/user/updateUser",
            data: {id,name,password},
            success(response) {
                if (response > 0){
                    alert("修改成功")
                    location.href = '/?target=user-list'
                }
            }
        })
    }
    location.href = '/?target=user-list'
}

window.addEventListener("load", function () {
    getUserId()
})